<input type="hidden" id="poll_op_status" value="<?php echo $this->session->flashdata('poll_op_status'); ?>" />
<script type="text/javascript">
  $(document).ready(function() {
    var poll_op_status = $.trim($('#poll_op_status').val());
    if (poll_op_status == 1) {
      toastr.success('Successfully opened poll');
    }
    if (poll_op_status == 2) {
      toastr.success('Successfully closed poll');
    }
    if (poll_op_status == 3) {
      toastr.success('Successfully deleted poll');
    }
    if (poll_op_status == 'error') {
      toastr.error('Error occured. Try again !');
    }
  });
</script>

<div class="page" style="min-height: 500px;">
  <div class="page-container">
    <div class="container">
      <div class="row">
        <div class="span3">
          <h4 class="header">Polls</h4>
          <div class="sidebar">
            <ul class="col-nav span3">
              <li <?php if ($polls_list_type == '' || $polls_list_type == 'active') { ?> style="background-color: #EEE;" <?php } ?>><a href="<?php echo base_url('polls?list_type=active'); ?>"><i class="pull-right icon-calendar"></i>Active polls</a></li>
              <li <?php if ($polls_list_type == 'new') { ?> style="background-color: #EEE;" <?php } ?>>
                <a href="<?php echo base_url('polls?list_type=new'); ?>">
                  <i class="pull-right icon-cog"></i>
                  <?php if (!empty($new_polls_count['new_polls_count'])) { ?>
                    <span title="<?php echo $new_polls_count['new_polls_count']; ?> new polls" class="label label-inverse pull-right" style="margin-right: 10px;"><?php echo $new_polls_count['new_polls_count']; ?></span>
                  <?php } ?>
                  New polls
                </a>
              </li>
              <li <?php if ($polls_list_type == 'top') { ?> style="background-color: #EEE;" <?php } ?>><a href="<?php echo base_url('polls?list_type=top'); ?>"><i class="pull-right icon-star"></i>Top polls</a></li>
              <li <?php if ($polls_list_type == 'my') { ?> style="background-color: #EEE;" <?php } ?>><a href="<?php echo base_url('polls?list_type=my'); ?>"><i class="pull-right icon-user"></i>My polls</a></li>
              <li <?php if ($polls_list_type == 'completed') { ?> style="background-color: #EEE;" <?php } ?>><a href="<?php echo base_url('polls?list_type=completed'); ?>"><i class="pull-right icon-lock"></i>Completed polls</a></li>
            </ul>
          </div>
          <div class="clearfix"></div>
          <div class="filters">
            <h5><a style="text-decoration: none; color: #555; font-weight: bold;">Counter</a></h5>
            <span class="pull-right"><?php echo $polls_count; ?></span>
            <label for="cb3">Total Polls</label>
          </div>
        </div>
        <div class="span9">
          <div class="btn-group pull-right"><a href="<?php echo base_url('polls/create'); ?>" class="btn pull-right">Create Poll</a></div>
          <h4 class="header">Polls</h4>
          <div class="stream">
            <?php if (!empty($polls_data)) { ?>
              <?php foreach ($polls_data as $polls) { ?>
                <div class="item">
                  <a href="<?php echo base_url('profile/' . $polls['user_name']); ?>"><img title="<?php echo $polls['user_display_name']; ?>" src="<?php echo base_url('assets/photos/' . $polls['user_image']); ?>" class="avatar"/></a>
                  <p class="date"><?php echo date('d - M - Y', strtotime($polls['poll_date'])); ?></p>
                  <h4>
                    <?php if ($polls['poll_status'] == 1) { ?>
                      <a style="text-decoration: none; word-break: break-all;" href="<?php echo base_url('polls/view/' . $polls['poll_id']); ?>"><?php echo mb_substr($polls['poll_message'], 0, 75) . '...'; ?></a>
                    <?php } else { ?>
                      <a style="text-decoration: none; word-break: break-all;" href="<?php echo base_url('polls/view_completed/' . $polls['poll_id']); ?>"><?php echo mb_substr($polls['poll_message'], 0, 75) . '...'; ?></a>
                    <?php } ?>
                    &nbsp;
                    <?php if (empty($polls['my_poll_reply_status'])) { ?>
                      <i style="cursor: pointer;" title="You haven't voted yet !" class="icon-large icon-info-sign"></i>
                    <?php } ?>
                  </h4>
                  <?php $get_user_like_status = get_user_like_status('poll', $polls['poll_id']); ?>
                  <p class="date" style="float: left; margin-top: 0px; color: #555;">
                    <span title="<?php echo $polls['poll_replies_count']; ?> votes" style="cursor: pointer;"><i class="icon-random"></i>&nbsp;:&nbsp;<?php echo $polls['poll_replies_count']; ?></span>&nbsp;|&nbsp;
                    <span title="<?php echo $get_user_like_status['total_count']; ?> likes" style="cursor: pointer;"><i class="icon-heart"></i>&nbsp;:&nbsp;<?php echo $get_user_like_status['total_count']; ?></span>&nbsp;|&nbsp;
                    <?php if ($polls['poll_show_users'] == 1) { ?>
                      <span title="You can see voted users" style="cursor: pointer;"><i class="icon-check"></i>&nbsp;:&nbsp;Public</span>&nbsp;|&nbsp;
                    <?php } else { ?>
                      <span title="You can't see voted users" style="cursor: pointer;"><i class="icon-check"></i>&nbsp;:&nbsp;Private</span>&nbsp;|&nbsp;
                    <?php } ?>
                    <span title="<?php echo '@' . $polls['user_name']; ?> started this poll" style="cursor: pointer;"><i class="icon-user"></i>&nbsp;:&nbsp;<?php echo '@' . $polls['user_name']; ?></span>
                  </p>
                </div>
              <?php } ?>
              <div id="load_more"></div>
              <?php if ($polls_count > $polls_limit) { ?>
                <div class="clearfix"></div>
                <div style="height: 10px;"></div>
                <?php if (!empty($polls_list_type)) { ?>
                  <?php $qry_str = '?list_type=' . $polls_list_type; ?>
                <?php } else { ?>
                  <?php $qry_str = '' ?>
                <?php } ?>
                <a id="load_more_button" style="text-decoration: none; cursor: pointer; float: right; color: black" href="<?php echo base_url('polls/' . ($polls_limit + 10) . $qry_str . '#load_more'); ?>" title="Load more polls">
                  <span>more</span>&nbsp;<i class="icon-large icon-chevron-down"></i>
                </a>
              <?php } ?>
            <?php } else { ?>
              <div class="item">
                <h4>Oops! No polls.</h4>
                <div class="row">
                  <p class="span6">
                    It will be awesome if you start a new poll !
                  </p>
                </div>
              </div>
            <?php } ?>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>